package com.djl.supports.interceptor;

import org.apache.ibatis.executor.parameter.ParameterHandler;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Signature;

import java.sql.Connection;
import java.sql.PreparedStatement;

@Intercepts({@Signature(type = ParameterHandler.class, method = "setParameters", args = { PreparedStatement.class}) })
public class ParameterInterceptor implements Interceptor {

    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        ParameterHandler statementHandler = (ParameterHandler)invocation.getTarget();
        Object parameterObject = statementHandler.getParameterObject();

        return invocation.proceed();
    }
}
